#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
typedef long long LL;
const int N = 100010;
int n,m;
int a[N],s[11][N];
int main()
{
	cin>>n>>m;
		for(int i=0;i<n;i++)
		cin>>a[i];
	for(int i=0;i<n;i++)
	{
	LL t = a[i]% m;
	for(int j=0;j< 11;j++)
	{
		s[j][t]++;
		t=t*10%m;			
		}		
	}
	LL res=0;
	for(int i=0;i<n;i++)
	{
		LL t = a[i]% m;
		int len=to_string(a[i]).size();
		res+=s[len][(m-t)%m];
		LL r =t;
		while(len--)
		r=r*10%m;
		if(r==(m-t)%m)res--;
				
	}
	printf("%lld\n",res);
	
	
	
	return 0;
 } 
